package com.example.controller;

import com.example.entity.Goods;
import com.example.service.GoodService;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/goods")
public class GoodsController {
    @Autowired
    private GoodService goodService;
    @GetMapping("/find/{id}")
    @HystrixCommand(fallbackMethod = "findFallback")
    public Goods find(@PathVariable("id") Integer id){
        int i = 1/0;
        return goodService.find(id);
    }
    public Goods findFallback(){
        return new Goods();
    }
}
